package com.itheima.tlias08_14.mapper;

import com.itheima.tlias08_14.dto.StatisticEmpGenderDTO;
import com.itheima.tlias08_14.entity.Department;
import com.itheima.tlias08_14.dto.SelectDeptDTO;
import com.itheima.tlias08_14.entity.DepartmentDTO;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

//@Mapper 将该接口注册为Mybatis的Mapper
@Mapper
public interface DepartmentMapper {

    @Select("select id , name , update_time from dept order by update_time desc")
    ArrayList<Department> selectAll();

    @Select("select id, name , update_time from dept order by update_time desc")
    ArrayList<SelectDeptDTO> selectAllDTO();

    @Insert("insert into dept (name,update_time,create_time) values(#{d.name},#{d.updateTime},#{d.createTime})")
    int insertDept(@Param("d")Department dept);

    @Delete("delete from dept where id = #{id}")
    int deleteDeptById(@Param("id")Integer id);

    @Select("select id, name , create_time ,update_time from dept where id = #{id}")
    SelectDeptDTO selectDeptById(@Param("id")Integer id);


    @Update("update dept set name = #{d.name},update_time = #{d.updateTime} where id = #{d.id}")
    int updateDept(@Param("d")Department dept);

    @Select("select * from dept where name = #{name}")
    Department selectDeptByName(@Param("name")String name);

    //批量增加部门信息
    int batchInset(@Param("list") List<Department> list);


    //批量删除部门信息
    int batchDelete(@Param("list") List<Integer> list);

    int batchInset01(@Param("list") List<DepartmentDTO> list);

    List<StatisticEmpGenderDTO> countDeptEmployee();


}
